package test;

public class SubsetXORSum2 {
	public int sum;
    public boolean[] check;
    public int path;
    public void dfs(int[] nums,int pos){
    	//结束收集结果
        if(pos==nums.length){
            sum+=path;
            return ;
        }

        //选i位置
        path^=nums[pos];
        dfs(nums,pos+1);
        path^=nums[pos];

        //不选i位置
        dfs(nums,pos+1);
    }
    public int subsetXORSum(int[] nums) {
        sum=path=0;
        check=new boolean[nums.length];
        dfs(nums,0);
        return sum;
    }
}
